import { createStore } from 'vuex'
import { getToken } from '@/utils/auth'
import { getUser } from '@/utils/user'

export default createStore({
  state: {
    user: getUser() || null,
  	token: getToken() || '',
  	uploadConfig: null,
    materialColor: null
  },
  getters: {
  },
  mutations: {
    SET_USER: (state, info) => {
      state.user = info
    },
    SET_TOKEN: (state, info) => {
      state.token = info
    },
    SET_UPLOAD_CONFIG: (state, info) => {
      state.uploadConfig = info
    },
    SET_MATERIAL_COLOR: (state, info) => {
      state.materialColor = info
    }
  },
  actions: {
    SET_USER({ commit }, info) {
      commit('SET_USER', info)
    },
    SET_TOKEN({ commit }, info) {
      commit('SET_TOKEN', info)
    },
    SET_UPLOAD_CONFIG({ commit }, info) {
      commit('SET_UPLOAD_CONFIG', info)
    },
    SET_MATERIAL_COLOR({ commit }, info) {
      commit('SET_MATERIAL_COLOR', info)
    },
  },
  modules: {
  }
})
